home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16444 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.9 KB

  1. Path: galaxy.ucr.edu!not-for-mail
  2. From: thp@cs.ucr.edu (Tom Payne)
  3. Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.edu
  4. Subject: Re: ANSI C and POSIX (was Re: C/C++ knocks the crap out of Ada)
  5. Date: 10 Apr 1996 21:38:31 GMT
  6. Organization: University of California, Riverside
  7. Message-ID: <4kh9on$jm@galaxy.ucr.edu>
  8. References: <JSA.96Feb16135027@organon.com> <dewar.828936837@schonberg>
  9. NNTP-Posting-Host: corvette.ucr.edu
  10. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  11.  
  12. Matt Austern (austern@isolde.mti.sgi.com) wrote:
  13. : In article <4kgmgu$jm@galaxy.ucr.edu> thp@cs.ucr.edu (Tom Payne) writes:
  14. : > The problem shows up in real situations: In C++ AFAIK there is no
  15. : > efficient way for an exception at the hardware level to generate an
  16. : > exception (in the C++ sense) on the part of the running program -- the
  17. : > running must poll a volatile atomic variable to see if the exception
  18. : > has occurred.  This obviously makes the langauge, as defined in the
  19. : > standard, unacceptable for use in the area of, say, embedded systems.
  20. : > Even in scientific progrmming, however, one would like to be able to
  21. : > throw an exception out of a matrix manipulation routine when the
  22. : > underlying hardware detects a floating point exception, and polling
  23. : > for such an occurrence would involve unacceptable overhead.
  24. : Are you sure that this is possible on the machines that you'd like
  25. : your program to run on?  On many of today's RISC chips, after all,
  26. : floating point exceptions are asynchronous: you have no way of
  27. : knowing which instruction caused the problem.
  28. : (This sounds perverse, but there's a reason for it.  If you want
  29. : synchronous exceptions, you end up having to stall the pipeline when
  30. : you're processing a floating point instruction.)
  31.  
  32. The scientific programming community has bad to put up with imprecise
  33. detection of floating point exceptions since the IBM 360/91, or
  34. before.  I'm not asking that a C/C++ implementation do anything more
  35. than pass the information along (via a signal) when it gets it.
  36. (That's why I said " ... when the underlying hardware detects a
  37. floating point exception ...".)
  38.  
  39. The problem, however, is not the timing of the resulting signal, but
  40. what I can (and can't) do within its handler.  The handler cannot read
  41. global data and, hence, cannot take any kind of corrective action.
  42. Also, it cannot throw an exception to unwind the computation back to
  43. some known state.  Other than aborting the computation, the only
  44. option left to a C/C++ signal handler is to set a flag that the
  45. program must poll to determine that a floating-point exception has
  46. occurred and to take corrective action such as throwing a C++
  47. exception.  I don't know Ada, but I doubt that it suffers the same
  48. limitation, and I expect that Gnat implements Ada on virtually all
  49. machines that run C/C++.  (To that extent, I am moderately sure that
  50. what I'm asking for is doable.)
  51.  
  52. Tom Payne (thp@cs.ucr.edu)
  53.  
  54.    
  55.